<!DOCTYPE html>
<html>
	<head>
		<base href="{$base_name}"/>
		<title>文章列表</title>
		<meta charset="utf-8" />
		<meta content="yes" name="apple-touch-fullscreen">
		<meta content="yes" name="apple-mobile-web-app-capable">
        <meta content="telephone=no,email=no" name="format-detection">
		<script type="text/javascript" src="libs/flexible_css.js"></script>
		<script type="text/javascript" src="libs/config.js"></script>
		<script type="text/javascript" src="libs/flexible.js"></script>
		<script type="text/javascript" src="libs/jquery-1.7.2.min.js"></script>
		<script type="text/javascript" src="libs/lazyload.js"></script>
		<link rel="stylesheet" type="text/css" href="css/club.css">
	</head>
	<body>
		<div id="container">
			<div class="el">
				
			</div>
		</div>
	</body>
</html>
<style>

</style>
<script id="tmpl" type="text/html">
{{# for(var i = 0, len = d.length; i < len; i++){ }}
<a href="javascript:void(0)" data-url="{{ d[i].url }}" data-id="{{ d[i].id }}" class="el-1">
	<div class="msg">
		<div class="heading">{{ d[i].title }}</div>
		<div class="amount {{ d[i].class_num }}">
			<p>{{ d[i].uname }}</p>
			<p>阅读：{{ d[i].read_num }}</p>
			<p>分享：{{ d[i].share_num }}</p>
		</div>
	</div>
	<img src="http://www.gbtags.com/gb/laitu/200x124&text=hello,zhiyou/ffffff" data-original="{{ d[i].img }}">
</a>
{{# } }}
</script>
<link rel="stylesheet" type="text/css" href="./layui/laytpl.css">
<script src="./layui/laytpl.js"></script>
<script>
function get_json_page(page,pagenum){
	if(is_last){
		$('.layui-flow-more').html('没有更多数据了');
		return false;
	}
	$.getJSON(root+'/class/index/?id='+id+'&pagenum='+pagenum+'&page='+page, function(data){
		//alert(data.data.length);
		if(data.status == 0){
			is_last = 1;
			$('.layui-flow-more').html('没有更多数据了');
			return false;
		}
		var len = data.data.length;
		if(len >0 && pagenum == len){
			$('.layui-flow-more cite').html('加载更多');
		}else{
			is_last = 1;
			$('.layui-flow-more').html('没有更多数据了');
		}
		
		for (var i = 0; i < len; i++) {
			++cur_num;
			var class_num = '';
			if(data.data[i].is_hot==1){
				class_num = 'fever';
			}
			data.data[i].class_num = class_num;
			data.data[i].cur_num = cur_num;
		}
		var dt = data.data;
		var gettpl = $('#tmpl').html();
		laytpl(gettpl).render(dt, function(html){
			$('#container .el').append(html);
		});
		$("img[data-original]").lazyload();
	});
}

var cur_num = 0;
var cur_page = 1;
var page_num = 4;
var is_last = 0;
//取得id值
var id = {$id};
//alert(hash);
//删除所有li
$('#container a').remove();
$('#container').append('<div class="layui-flow-more"><a href="javascript:;"><cite>加载更多</cite></a></div>');
get_json_page(cur_page,page_num);

</script>
<script>
$('.layui-flow-more').click(function(){
	get_json_page(++cur_page,page_num);
});
</script>
<script>
$('[data-url]').live('click',function(){
	var addurl = root + '/class/add_readnum/?id='+$(this).attr('data-id');
	var url = $(this).attr('data-url');
	$.getJSON(addurl, function(data){
		
		location.href = url;
		return false;
	});
});
</script>
